import java.util.Arrays;
import java.util.Scanner;

public class Test {
    //
    public static void func1(int[] array){
        int i = 0;
        int j = array.length-1;
        while (i < j){
            while (i < j && array[i]%2 == 1){
                i++;
            }//确保i在j前面，使array[i]为偶数
            while (i < j && array[j]%2 == 0){
                j--;
            }//确保j在i后面，使array[j]为奇数
            int tmp = array[i];
            array[i] = array[j];
            array[j] = tmp;
        }
    }
    public static void main(String[] args) {
        int[] array = {1,3,6,8,11,5,2,9};
        func1(array);
        System.out.println(Arrays.toString(array));
    }
















    //递归实现n的阶乘
    public static int func(int n){
        if (n == 1){
            return 1;
        }
        else {
            return n * func(n - 1);
        }
    }
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int ret = func(a);
        System.out.println(ret);


    }















    public static int sum(int n){
        //递归实现数字和
        if(n == 1){
            return 1;
        }
        return n + sum(n-1);// 递归调用
    }
    public static void BobbleSort(int[] a) {
        // 获取a的元素个数
        int n = a.length;
        for(int i = 0; i < n-1; ++i)
        {
            for(int j = 0; j < n - i - 1; ++j)
            {
                if(a[j] > a[j + 1]) {
                    int tmp = a[j];
                    a[j] = a[i];
                    a[i] = tmp;
                }
            }
        }
    }

    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        System.out.println(sum(a));
//        int[] a = {9,8,7,6,5,4,3,2,1,0};
//        BobbleSort(a);
//        for (int j : a) {
//            System.out.print(j);
//        }
    }
}
